<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .error {
        outline: none;
        border-color: red;
      }
      .success {
        outline: none;
        border-color: green;
      }
    </style>
  </head>
  <body>
    <div id="app"></div>
    <template id="t1">
      <div>
        <form id="form">
          <p>
            姓名
            <!-- 数据的双向绑定 -->
            <input
              type="text"
              :value="form.username"
              @input="form.username = $event.target.value"
            />

            form.username:{{form.username}}
          </p>
        </form>
      </div>
    </template>
    <script src="./vue.js"></script>
    <script>
      const vm = new Vue({
        el: "#app",
        template: "#t1",
        data: {
          form: {
            // 数据->视图
            username: "jack",
          },
        },
        methods: {
          // setValue(e) {
          //   // 视图->数据
          //   this.form.username = e.target.value;
          // },
        },
      });
    </script>
  </body>
</html>
